#ifndef __SEARCHENGINESERVER_H__
#define __SEARCHENGINESERVER_H__

#include "TcpConnection.h"
#include "TcpServer.h"
#include "ThreadPool.h"
#include "../WebPageSearcher.h"
#include "../KeyRecommander.h"
#include "ProtocolParser.h"

class ProtocolParser;

class SearchEngineServer{
public:
    SearchEngineServer(size_t threadNum,size_t queSize
                       ,const string &ip
                       ,unsigned short port);
    
    ~SearchEngineServer();

    void start();

    void stop();

    void onNewConnection(const TcpConnectionPtr &con);
    void onMessage(const TcpConnectionPtr &con);
    void onClose(const TcpConnectionPtr &con);

    void doTaskThread(const TcpConnectionPtr &conn,string &msg);
private:
    ThreadPool _pool;
    TcpServer _server;
};

#endif
